<template>
  <div class="right">
    <h1 class="chart-title">
      男女干警比例
    </h1>
    <div class="sex-chart" id="sexChart">
      <div>
        <svg>
          <defs>
            <linearGradient id="innerBall" x1="0%" x2="0%" y1="0%" y2="100%">
              <stop offset="0%" stop-color="green" />
              <stop offset="100%" stop-color="gold" />
            </linearGradient>
          </defs>
        </svg>
      </div>
      <div>
        <p class="male">
          男性 {{male}}%
        </p>
        <p class="female">
          女性 {{female}}%
        </p>
      </div>

    </div>
  </div>
</template>


<script>
import axios from "axios"
import waterBall from "../assets/scripts/charts/waterBall"
export default {
  data() {
    return {
      male: 0,
      female: 0
    }
  },

  async created() {
    let result = await axios.get("/api/overview/sex")
    let { male, female } = result.data.data
    this.male = male
    this.female = female
    var ball = new waterBall("#sexChart", {})
    ball.render(result.data.data)
  }
}
</script>


<style lang="scss" scoped>
.right {
  position: absolute;
  top: 200px;
  right: 100px;
}

.sex-chart {
  display: flex;
  font-size: 40px;
  color: white;
  align-items: center;
  height: 500px;
}

.sex-chart div:first-child {
  flex: 1;
}

.sex-chart div:last-child {
  flex: 1;
}

.sex-chart p {
  line-height: 50px;
}
</style>


